package scau.redi.social_platform.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import scau.redi.social_platform.dao.SharedImgMapper;
import scau.redi.social_platform.domain.pojo.Shared;
import scau.redi.social_platform.domain.pojo.SharedImg;
import scau.redi.social_platform.service.SharedImgService;

/**
 * @Author: Redi
 * @Date: 2022/5/8 10:36
 * @Description:
 */
@Service
public class SharedImgServiceImpl implements SharedImgService {

    @Autowired
    SharedImgMapper sharedImgMapper;

    @Override
    public int createSharedImg(SharedImg sharedImg) {
        if (sharedImgMapper.insertSelective(sharedImg)>0){
            return sharedImgMapper.selectLastInsertId();
        }
        return 0;
    }

    @Override
    public int deleteSharedImg(int sharedImgId) {
        return sharedImgMapper.deleteByPrimaryKey(sharedImgId);
    }

    @Override
    public int updateSharedImg(SharedImg sharedImg) {
        return sharedImgMapper.updateByPrimaryKeySelective(sharedImg);
    }

    @Override
    public SharedImg findById(int sharedImgId) {
        return sharedImgMapper.selectByPrimaryKey(sharedImgId);
    }
}
